package cn.edu.zafu.bigdata.x.zzzznnn;

public class StaticDemo {
    static int count = 0;
    int id;
    static {
        System.out.println("Static block executed");
        count = 0;
    }

    {
        System.out.println("Instance block executed");
        this.id = count;
        count++;
    }
    public StaticDemo() {
        System.out.println("Constructor executed for ID: " + this.id);
    }
    public static void displayCount() {
        System.out.println("Total instances created: " + count);
    }
    public static void main(String[] args) {
        StaticDemo obj1 = new StaticDemo();
        StaticDemo obj2 = new StaticDemo();
        StaticDemo.displayCount();
    }
}
